
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="关闭">
        <span aria-hidden="true">×</span>
    </button>
    <h4 class="modal-title">添加用户</h4>
</div>
<div class="modal-body" style="overflow: auto; height: 200px;">
    <form class="form-horizontal">
        {% csrf_token %}
        <div class="form-group">
            <label class="col-md-2 control-label" for="name">姓名</label>
            <div class="col-md-8">
                <input type="text" class="form-control input-md" id="name" name="name" placeholder="请输入员工姓名" value="">
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label" for="phone">手机号</label>
            <div class="col-md-8">
                <input type="text" class="form-control input-md" id="phone" name="phone" placeholder="请输入员工手机号" value="">
            </div>
        </div>
        <div class="form-group">
            <label class="col-md-2 control-label" for="sex">性别</label>
            <div class="col-md-8">
                <div class="radio-custom radio-default radio-inline">
                    <input type="radio" id="inputSexMale" name="sex" value="2">
                    <label for="inputSexMale">男</label>
                </div>
                <div class="radio-custom radio-default radio-inline">
                    <input type="radio" id="inputSexFemale" name="sex" value="1">
                    <label for="inputSexFemale">女</label>
                </div>
            </div>
        </div>
        <p style="color: red;">初始密码: 123 , 首次登录强制修改密码</p>
    </form>

</div>
<div class="modal-footer">
    <button type="button" class="btn btn-primary" id="staff_modal_create_button">添加用户</button>
</div>

<script>

    (function ($) {

        $("#staff_modal_create_button").on('click', function () {
            var data = $(".form-horizontal").serialize();
            var url = "/userprofile/create/" + 0 + '/';

            $.post(url, data, function (result) {
                if(!result['status']){
                    toastr['error'](result['message']);

                }else{
                    toastr['success'](result['message']);

                    setTimeout(function () {
                        location.reload()
                    }, 1000);

                }
            }, 'json')

        });

{#        // 展开收起部门信息#}
{#        $(".modal .treeview span").on('click', function () {#}
{#            event.stopPropagation();#}
{#            if (!$(this).hasClass('expand-icon')){#}
{#                return false;#}
{#            }#}
{##}
{#            var level = $(this).parent('li').attr('level');#}
{##}
{#            var li_tags = $(this).parent('li').nextAll();   // 当前点击部门后面的所有部门#}
{##}
{#            // 展开#}
{#            if ($(this).hasClass('wb-plus')){#}
{##}
{#                $(this).removeClass('wb-plus');#}
{#                $(this).addClass('wb-minus');#}
{#                li_tags.each(function () {#}
{#                    var now_level = $(this).attr('level');#}
{#                    if(now_level > level){#}
{#                        $(this).removeClass('hidden')#}
{#                    }else{#}
{#                        return false#}
{#                    }#}
{#                });#}
{#            }#}
{#            // 缩起#}
{#            else{#}
{#                $(this).removeClass('wb-minus');#}
{#                $(this).addClass('wb-plus');#}
{#                li_tags.each(function () {#}
{#                    var now_level = $(this).attr('level');#}
{#                    if(now_level > level){#}
{#                        $(this).addClass('hidden')#}
{#                    }else{#}
{#                        return false#}
{#                    }#}
{##}
{#                });#}
{#            }#}
{#        });#}
{##}
{#        // 修改部门信息中模态对话框中的部门被点击#}
{#        $("#modal .treeview li").on('click', function () {#}
{#            var now_id = $(this).attr('data-nodeid');#}
{#            $(this).parent().find('li').removeClass('active');#}
{#            $(this).addClass('active');#}
{#            $(".form-horizontal input[name='parent_id']").val(now_id)#}
{##}
{#        });#}
{##}
{#        // 修改部门信息中模态对话框中的修改按钮被点击#}
{#        $("#department_modal_create_button").on('click', function () {#}
{##}
{#            var data = $(".form-horizontal").serialize();#}
{#            var url = "/admin/department/create/" + 0 + '/';#}
{##}
{#            $.post(url, data, function (result) {#}
{#                if(!result['status']){#}
{#                    $("#err_toastrRight").attr('data-message', result['message']);#}
{#                    $("#err_toastrRight").click();  // 触发点击事件#}
{#                }else{#}
{#                    $("#sucsess_toastrRight").attr('data-message', result['message']);#}
{#                    $("#sucsess_toastrRight").click();  // 触发点击事件#}
{##}
{#                    setTimeout(function () {#}
{#                        location.reload()#}
{#                    }, 1000);#}
{##}
{#                }#}
{#            }, 'json')#}
{##}
{#        });#}




    })(jQuery)

</script>
